<template>
	<view>
		<view :style="'background-image:url('+get_img+bgFunc()+');'" class="image">
			<!-- <image class="image" :src='get_img + sys.egg_bg'></image> -->
		</view>
		<view>
			<image class="image1" :src='get_img + sys.coupongoods_icon'></image>
		</view>
		<view class="active">
			<u-tabs :list="list1" @click="click" :scrollable='scrollable' :activeStyle='activeStyle' :inactiveStyle='inactiveStyle'></u-tabs>
		</view>
		<view class="convert" v-for="(item,index) in list" :key="index" v-if="item.state==state">
			<view class="zuo">
				<image :src="get_img + item.goods.image" class="img"></image>
			</view>
			<view class="kuai">
				<view class="zuo">
					<p class="content_p">{{item.goods.shop_name}}</p>
					<p class="updated_p">{{item.goods.name}}</p>
				</view>
				<view style="float: right;">

					<view class="hx">
						<u-tag v-if="item.state==0" text="核销码" type="error" size="mini" shape="circle" @click="hx(item)"></u-tag>
					</view>
				</view>
			</view>
			<view class="_a">
				<u-line color="#fff" hairline="false"></u-line>
			</view>
		</view>
		<u-popup :show="show" mode="center" @close="close" @open="open" closeable="true">
			<view class="jphx">
				<text>奖品核销</text>
			</view>
			<image :src='get_img+qrcode' class="jphx_img"></image>
		</u-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list1: [{
					name: '待领取',
				}, {
					name: '已领取',
				}],
				get_img: this.$get_img,
				state: 0,
				is_reach: false,
				qrcode: "",
				show: false,
				page: 1,
				num: 10,
				activeStyle: {
					color: '#fff'
				},
				inactiveStyle: {
					color: '#fff'
				},
				sys: {},
				list: [],
				goods: {},
			}
		},
		onLoad() {
			this.sys = uni.getStorageSync("sys")
			this.get_log()
		},
		onReachBottom() {
			if (!this.is_reach) {
				this.page++
				this.get_log()
			}

		},
		methods: {
			bgFunc() {
				return this.sys.coupon_bg != '' ? this.sys.coupongoods_bg : this.sys.sys_background
			},

			open() {
				console.log('open');
			},
			get_log() {
				let that = this
				this.$model.get("user/goods/get_order?state=" + this.state + "&page=" + this.page + "&num=" + this.num)
					.then(res => {
						if (res.code == 200) {
							if (res.data.data.length == 0) {
								uni.showToast({
									title: "没有更多了"
								})
								that.is_reach = true
							}
							res.data.data.forEach(function(value) {
								that.list.push(value)
							})
						}
					})
			},
			click(item) {
				this.state = item.index
				this.page = 1
				this.list = []
				this.get_log()
			},
			hx(item) {
				this.qrcode = item.qrcode;
				this.show = true
				console.log("item1111:", item)
			},

			close() {
				this.show = false

			},
			exchange(item) {
				console.log("item:", item)
				uni.navigateTo({
					url: "../coupon/entertainmetn_list"
				})
			}
		}

	}
</script>

<style>
	.image {
		background-repeat: no-repeat;
		background-size: 100% 100%;
		background-attachment: fixed;
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		height: 100vh;
		z-index: -1;
		background-image: url('https://cdn.uviewui.com/uview/album/1.jpg');
	}

	._a {
		width: 750rpx;
		margin-top: -20rpx;

	}

	.jphx {
		text-align: center;
		color: orangered;
	}

	.image1 {
		width: 100vw;
		height: 150px;
	}

	.active {
		color: #fff;
		background-color: rgba(255, 255, 255, .5);
		margin: -10rpx 0 0 0;

	}

	.kuai {
		width: 580rpx;
		height: 180rpx;
		float: right;
	}

	.jphx_img {
		width: 400rpx;
		height: 400rpx;
	}

	.active_1 {
		background-color: rgba(255, 255, 255, .5);
		/* margin: -200rpx 200rpx 0 260rpx; */
		height: 150rpx;
		width: 480rpx;
	}

	.convert {
		width: 100vw;
		height: 200rpx;
		color: #000;
		/* margin-top: 20rpx; */
		float: right;
		/* background-color: rgba(0, 0, 0, .5); */

	}

	.hx {
		margin-top: 30rpx;
		margin-right: 30rpx;
	}

	.receive {
		width: 150rpx;
		height: 70rpx;
		margin-left: 350rpx;
		/* margin-top: -188rpx; */
	}

	.content_p {
		margin: 30rpx 20rpx 20rpx 20rpx;
		font-size: 35rpx;
		color: #fff;
	}

	.updated_p {
		margin: 0rpx 20rpx 50rpx 20rpx;
		font-size: 30rpx;
		color: #fff;
	}

	.img {
		width: 150rpx;
		height: 150rpx;
		margin: 10rpx 0rpx 20rpx 20rpx;
		float: left;
	}

	.zuo {
		float: left;
	}
</style>
